<template>
  <div class="mittTest">
    <h1>接收数据的组件:绑定事件\同时在销毁前解绑事件</h1>
  </div>
</template>
<script lang="ts" setup>
import { onUnmounted, onMounted } from "vue";
import emitter from "@/utils/emitter";
// 绑定事件
emitter.on("send-toy", (val) => {
  console.log("send-toy事件被触发", val);
});
onUnmounted(() => {
  // 解绑事件
  emitter.off("send-toy");
});
</script>
<style scoped>
.mittTest {
  width: 80vw;
  height: 80vh;
  border: 1px solid red;
}
</style>
